#include<bits/stdc++.h>
#define ll long long
#define int ll
#define L xd[x].l
#define R xd[x].r
#define mid (l+r>>1)
#define lc L,l,mid
#define rc R,mid+1,r
#define OK Ll<=l&&r<=Rr
#define Root 1,1,n
#define rep(x,y,z) for(int x=(y);x<=(z);x++)
#define per(x,y,z) for(int x=(y);x>=(z);x--)
#define pb push_back
#define ull unsigned ll
#define e(x) for(int i=h[x],y=to[i];i;i=nxt[i],y=to[i])
#define E(x) for(auto y:p[x])
#define Pi pair<int,int>
#define ui unsigned ll
inline int read(){int s=0,w=1;char c=getchar();while(c<48||c>57) {if(c=='-') w=-1;c=getchar();}while(c>=48&&c<=57)s=(s<<1)+(s<<3)+c-48,c=getchar();return s*w;}
inline void pf(ll x){if(x<0) putchar('-'),x=-x;if(x>9)pf(x/10);putchar(x%10+48);}
const signed N =2e5+5,M=1e6+5,inf=(1LL<<31)-1;
using namespace std;
int T=1,n,a[N],k,h[N],to[N<<1],nxt[N<<1],cnt;
bool sig[N];
inline void add(int a,int b){
	to[++cnt]=b,nxt[cnt]=h[a],h[a]=cnt;
}
int dep[N],mx[N];
inline void dfs(int x,int fa){
	dep[x]=dep[fa]+1;
	mx[x]=-inf;
	if(sig[x])mx[x]=dep[x];
	e(x)if(y^fa)dfs(y,x),mx[x]=max(mx[x],mx[y]);
}
int mxk[N],ans;//disx=dep[x]+k[x]
inline void Dfs(int x,int fa,int mindp){
	int mxnow=-inf;
	if(sig[x])mindp=min(mindp,dep[x]);
	ans=min(ans,max({mx[x]-dep[x],dep[x]+mxk[x],dep[x]-mindp}));
	vector<int>s;
	e(x)if(y^fa){
		s.pb(y),mxk[y]=max(mxk[y],mxnow);
		mxnow=max(mxnow,mx[y]-dep[x]*2);
	}
	int siz=s.size();
	mxnow=-inf;
	per(i,siz-1,0){
		int y=s[i];
		mxk[y]=max({mxk[y],mxk[x],mxnow});
		mxnow=max(mxnow,mx[y]-dep[x]*2);
		Dfs(y,x,mindp);
	}
}
signed main(){
	while(T--){
		n=read(),k=read();
		rep(i,1,n)h[i]=sig[i]=0,mxk[i]=-inf;
		cnt=0;
		rep(i,1,k)sig[read()]=1;
		for(int i=1,x,y;i^n;i++)x=read(),y=read(),add(x,y),add(y,x);
		ans=inf;
		dfs(1,0),Dfs(1,0,inf);
		pf(ans),putchar('\n');
	}
	return 0;
}
